jail: fs: don't overwrite existing mount target
authorDaniel Golle <[email protected]>
Thu, 12 Jan 2023 17:57:51 +0000 (17:57 +0000)
committerDaniel Golle <[email protected]>
Mon, 16 Jan 2023 21:07:38 +0000 (21:07 +0000)
commit04d7570f473ca2a657a89f74ac4027f6c94f4305
tree93d712e41970731e0cb8899518b79fd0b0b1faed
parent039b88f75367203e540009cc97603b1bce3fafa6
jail: fs: don't overwrite existing mount target

Using the creat() function overwrites existing files which is
unintended when it comes to making sure the target of a single-file
mount exists. Instead, use open() with the O_EXCL flag to make sure
mount targets are only created if actually needed.

While at it also clean up various error paths of the do_mounts
function, making sure the additionally allocated string being created
for the path inside the jail's root filesystem is always freed
and also making it a bit more readable and less bloated.

Signed-off-by: Daniel Golle <[email protected]>
jail/fs.c